import java.math.*;

public class test {
    public static void main(String[] args) {
        int[] plain = hexToInt(args[0]);
        int[] key = hexToInt(args[1]);
        int[] cipher = SM4Turn.encrypt(plain, key);
        System.out.println(intToHex(cipher));
    }

    public static int[] hexToInt(String p) {
        int[] pp = new int[4];
        for(int i = 0; i < p.length(); i += 8) {
            pp[i/8] = Integer.parseUnsignedInt(p.substring(i, i + 8), 16);
        }
        return pp;
    }

    public static String intToHex(int[] w) {
        StringBuilder hex = new StringBuilder();
        for(int i = 0; i < w.length; i++) {
            hex.append(Integer.toHexString(w[i]));
        }
        return hex.toString();
    }
}